Hệ thống quản lý phòng khám trực tuyến bằng PHP

1 <?php
2     
/* initial preps and includes */
3     error_reporting(E_ERROR | E_WARNING | E_PARSE);
4     
if(function_exists('set_magic_quotes_runtime')) @set_magic_quotes_runtime(0);
5     $curr_dir = dirname(__FILE__);
6     include(
"$curr_dir/settings-manager.php");
7     include(
"$curr_dir/defaultLang.php");
8     include(
"$curr_dir/language.php");
9     include(
"$curr_dir/db.php");
10
11     
/*
12         Determine execution scenario ...
13         
this script is called in 1 of 5 scenarios:
14             
1. to display the setup instructions no $_GET['show-form']
15             
2. to display the setup form $_GET['show-form'], no $_POST['test'], no $_POST['submit']
16             
3. to test the db info, $_POST['test'] no $_POST['submit']
17             
4. to save setup data, $_POST['submit']
18             
5. to show final success message, $_GET['finish']
19         below here, we determine which scenario
is being called
20     */

21     $submit = $test = $form = $finish =
false;
22     (isset($_POST[
'submit']) ? $submit = true :
23     (isset($_POST[
'test']) ? $test = true :
24     (isset($_GET[
'show-form']) ? $form = true :
25     (isset($_GET[
'finish']) ? $finish = true :
26         
false))));
27
28
29     
/* some function definitions */
30     function undo_magic_quotes($str){
31         
return (get_magic_quotes_gpc() ? stripslashes($str) : $str);
32     }
33
34     function isEmail($email){
35         
if(preg_match('/^([*+!.&#$¦\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,45})$/i', $email)){
36             
return $email;
37         }
else{
38             
return FALSE;
39         }
40     }
41
42     function setup_allowed_username($username){
43         $username = trim(strtolower($username));
44         
if(!preg_match('/^[a-z0-9][a-z0-9 _.@]{3,19}$/', $username) || preg_match('/(@@| |\.\.|___)/', $username)) return false;
45         
return $username;
46     }
47
48
49     
/* if config file already exists, no need to continue */
50     
if(!$finish && detect_config(false)){
51         @header(
'Location: index.php');
52         exit;
53     }
54
55
56
57     
/* include page header, unless we're testing db connection (ajax) */
58     
if(session_id()){ @session_write_close(); }
59     @session_name(
'online_clinic_management_system');
60     @session_start();
61     $_REQUEST[
'Embedded'] = 1; /* to prevent displaying the navigation bar */
62     $x =
new StdClass;
63     $x->TableTitle = $Translation[
'Setup Data']; /* page title */
64     
if(!$test) include_once("$curr_dir/header.php");
65
66     
if($submit || $test){
67
68         
/* receive posted data */
69         
if($submit){
70             $username = setup_allowed_username($_POST[
'username']);
71             $email = isEmail($_POST[
'email']);
72             $password = $_POST[
'password'];
73             $confirmPassword = $_POST[
'confirmPassword'];
74         }
75         $db_name = str_replace(
'`', '', $_POST['db_name']);
76         $db_password = $_POST[
'db_password'];
77         $db_server = $_POST[
'db_server'];
78         $db_username = $_POST[
'db_username'];
79
80         
/* validate data */
81         $errors = array();
82         
if($submit){
83             
if(!$username){
84                 $errors[] = $Translation[
'username invalid'];
85             }
86             
if(strlen($password) < 4 || trim($password) != $password){
87                 $errors[] = $Translation[
'password invalid'];
88             }
89             
if($password != $confirmPassword){
90                 $errors[] = $Translation[
'password no match'];
91             }
92             
if(!$email){
93                 $errors[] = $Translation[
'email invalid'];
94             }
95         }
96
97         
/* test database connection */
98         
if(!($connection = @db_connect($db_server, $db_username, $db_password))){
99             $errors[] = $Translation[
'Database connection error'];
100         }
101         
if($connection !== false && !@db_select_db($db_name, $connection)){
102             
// attempt to create the database
103             
if(!@db_query("CREATE DATABASE IF NOT EXISTS `$db_name`")){
104                 $errors[] = @db_error($connection);
105             }elseif(!@db_select_db($db_name, $connection)){
106                 $errors[] = @db_error($connection);
107             }
108         }
109
110         
/* in case of validation errors, output them and exit */
111         
if(count($errors)){
112             
if($test){
113                 echo
'ERROR!';
114                 exit;
115             }
116
117             ?>
118                 <div
class="row">
119                     <div
class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
120                         <h2
class="text-danger"><?php echo $Translation['The following errors occured']; ?></h2>
121                         <div
class="alert alert-danger"><ul><li><?php echo implode('</li><li>', $errors); ?></li></ul></div>
122                         <a
class="btn btn-default btn-lg vspacer-lg" href="#" onclick="history.go(-1); return false;"><i class="glyphicon glyphicon-chevron-left"></i> <?php echo $Translation['< back']; ?></a>
123                     </div>
124                 </div>
125             <?php
126             include_once(
"$curr_dir/footer.php");
127             exit;
128         }
129
130         
/* if db test is successful, output success message and exit */
131         
if($test){
132             echo
'SUCCESS!';
133             exit;
134         }
135
136         
/* create database tables */
137         $silent =
false;
138         include(
"$curr_dir/updateDB.php");
139
140
141         
/* attempt to save db config file */
142         $new_config = array(
143             
'dbServer' => undo_magic_quotes($db_server),
144             
'dbUsername' => undo_magic_quotes($db_username),
145             
'dbPassword' => undo_magic_quotes($db_password),
146             
'dbDatabase' => undo_magic_quotes($db_name),
147
148             
'adminConfig' => array(
149                 
'adminUsername' => $username,
150                 
'adminPassword' => md5($password),
151                 
'notifyAdminNewMembers' => false,
152                 
'defaultSignUp' => 1,
153                 
'anonymousGroup' => 'anonymous',
154                 
'anonymousMember' => 'guest',
155                 
'groupsPerPage' => 10,
156                 
'membersPerPage' => 10,
157                 
'recordsPerPage' => 10,
158                 
'custom1' => 'Full Name',
159                 
'custom2' => 'Address',
160                 
'custom3' => 'City',
161                 
'custom4' => 'State',
162                 
'MySQLDateFormat' => '%m/%d/%Y',
163                 
'PHPDateFormat' => 'n/j/Y',
164                 
'PHPDateTimeFormat' => 'm/d/Y, h:i a',
165                 
'senderName' => 'Membership management',
166                 
'senderEmail' => $email,
167                 
'approvalSubject' => 'Your membership is now approved',
168                 
'approvalMessage' => "Dear member,\n\nYour membership is now approved by the admin. You can log in to your account here:\nhttp://{$_SERVER['HTTP_HOST']}" . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "\n\nRegards,\nAdmin",
169                 
'hide_twitter_feed' => false,
170                 
'maintenance_mode_message' => '<b>Our website is currently down for maintenance</b><br>\r\nWe expect to be back in a couple hours. Thanks for your patience.',
171                 
'mail_function' => 'mail',
172                 
'smtp_server' => '',
173                 
'smtp_encryption' => '',
174                 
'smtp_port' => 25,
175                 
'smtp_user' => '',
176                 
'smtp_pass' => ''
177             )
178         );
179
180         $save_result = save_config($new_config);
181         
if($save_result !== true){
182             
// display instructions for manually creating them if saving not successful
183             $folder_path_formatted =
'<strong>' . dirname(__FILE__) . '</strong>';
184             ?>
185                 <div
class="row">
186                     <div
class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
187                         <p style=
"background-color: white; padding: 20px; margin-bottom: 40px; border-radius: 4px;"><img src="logo.png"></p>
188                         <div
class="alert alert-danger"><?php echo $Translation['error:'] . ' ' . $save_result['error']; ?></div>
189                         <?php printf($Translation[
'failed to create config instructions'], $folder_path_formatted); ?>
190                         <pre style=
"overflow: scroll; font-size: large;"><?php echo htmlspecialchars($save_result['config']); ?></pre>
191                     </div>
192                 </div>
193             <?php
194             exit;
195         }
196
197
198         
/* sign in as admin if everything went ok */
199         $_SESSION[
'adminUsername'] = $username;
200         $_SESSION[
'memberID'] = $username;
201         $_SESSION[
'memberGroupID'] = 2; // this should work fine in most cases
202
203
204
205         
/* redirect to finish page using javascript */
206         ?>
207         <script>
208             jQuery(function(){
209                 
var a = window.location.href + '?finish=1';
210
211                 
if(jQuery('div[class="text-danger"]').length){
212                     jQuery(
'body').append('<p class="text-center"><a href="' + a + '" class="btn btn-default vspacer-lg"><?php echo addslashes($Translation['Continue']); ?> <i class="glyphicon glyphicon-chevron-right"></i></a></p>');
213                 }
else{
214                     jQuery(
'body').append('<div id="manual-redir" style="width: 400px; margin: 10px auto;">If not redirected automatically, <a href="<?php echo basename(__FILE__); ?>?finish=1">click here</a>!</div>');
215                     window.location = a;
216                 }
217             });
218         </script>
219         <?php
220
221         
// exit
222         include_once(
"$curr_dir/footer.php");
223         exit;
224     }elseif($finish){
225         detect_config();
226         @include(
"$curr_dir/config.php");
227     }
228 ?>
229
230     <div
class="row"><div class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
231     <?php
232         
if(!$form && !$finish){ /* show checks and instructions */
233
234             
/* initial checks */
235             $checks = array();
/* populate with array('class' => 'warning|danger', 'message' => 'error message') */
236
237             
if(!extension_loaded('mysql') && !extension_loaded('mysqli')){
238                 $checks[] = array(
239                     
'class' => 'danger',
240                     
'message' => 'ERROR: PHP is not configured to connect to MySQL on this machine. Please see <a href=http://www.php.net/manual/en/ref.mysql.php>this page</a> for help on how to configure MySQL.'
241                 );
242             }
243
244             
if(!extension_loaded('iconv')){
245                 $checks[] = array(
246                     
'class' => 'warning',
247                     
'message' => 'WARNING: PHP is not configured to use iconv on this machine. Some features of this application might not function correctly. Please see <a href=http://php.net/manual/en/book.iconv.php>this page</a> for help on how to configure iconv.'
248                 );
249                 ?>
250                     <div
class="alert alert-warning alert-dismissable">
251                         <button type=
"button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
252                         
253                     </div>
254                 <?php
255             }
256
257             
if(!extension_loaded('gd')){
258                 $checks[] = array(
259                     
'class' => 'warning',
260                     
'message' => 'WARNING: PHP is not configured to use GD on this machine. This will prevent creating thumbnails of uploaded images. Please see <a href=http://php.net/manual/en/book.image.php>this page</a> for help on how to configure GD.'
261                 );
262             }
263
264             
if(!@is_writable("{$curr_dir}/images")){
265                 $checks[] = array(
266                     
'class' => 'warning',
267                     
'message' => 'WARNING: <dfn><abbr title="' . dirname(__FILE__) . '/images">images</abbr></dfn> folder is not writeable. This will prevent file uploads from working correctly. Please set that folder as writeable (for example, <code>chmod 777</code> in linux.)'
268                 );
269             }
270
271             
if(count($checks) && !isset($_POST['test'])){
272                 $stop_setup =
false;
273                 ?>
274                 <div
class="panel panel-warning vspacer-lg">
275                     <div
class="panel-heading"><h3 class="panel-title">Warnings</h3></div>
276                     <div
class="panel-body">
277                         <?php
foreach($checks as $chk){ if($chk['class'] == 'danger'){ $stop_setup = true; } ?>
278                             <div
class="text-<?php echo $chk['class']; ?> vspacer-lg">
279                                 <i
class="glyphicon glyphicon-<?php echo ($chk['class'] == 'danger' ? 'remove' : 'exclamation-sign'); ?>"></i>
280                                 <?php echo $chk[
'message']; ?>
281                             </div>
282                         <?php } ?>
283                         <a href=
"setup.php" class="btn btn-success pull-right vspacer-lg hspacer-lg"><i class="glyphicon glyphicon-refresh"></i> Recheck</a>
284                     </div>
285                     <?php
if($stop_setup){ ?>
286                         <div
class="panel-footer">You must fix at least the issues marked with <i class="glyphicon glyphicon-remove text-danger"></i> before continuing ...</div>
287                     <?php } ?>
288                 </div>
289                 <?php
290                 
if($stop_setup) exit;
291             }
292         ?>
293
294         <div id=
"intro1" class="instructions">
295             <p style=
"background-color: white; padding: 20px; margin-bottom: 40px; border-radius: 4px;"><img src="logo.png"></p>
296             <p><?php echo $Translation[
'setup intro 1']; ?></p>
297             <br><br>
298             <p
class="text-center"><button class="btn btn-default" id="show-intro2" type="button"><?php echo $Translation['Continue']; ?> <i class="glyphicon glyphicon-chevron-right"></i></button></p>
299         </div>
300
301         <div id=
"intro2" class="instructions" style="display: none;">
302             <p style=
"background-color: white; padding: 20px; margin-bottom: 40px; border-radius: 4px;"><img src="logo.png"></p>
303             <p><?php echo $Translation[
'setup intro 2']; ?></p>
304             <br><br>
305             <p
class="text-center"><button class="btn btn-success btn-lg" id="show-login-form" type="button"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['Lets go']; ?></button></p>
306         </div>
307
308     <?php }elseif($form){
/* show setup form */ ?>
309
310         <div
class="page-header"><h1><?php echo $Translation['Setup Data']; ?></h1></div>
311
312         <form method=
"post" action="<?php echo basename(__FILE__); ?>" onSubmit="return jsValidateSetup();" id="login-form" style="display: none;">
313             <fieldset id=
"database" class="form-horizontal">
314                 <legend><?php echo $Translation[
'Database Information']; ?></legend>
315
316                 <div
class="form-group">
317                     <label
for="db_server" class="control-label col-sm-4"><?php echo $Translation['mysql server']; ?></label>
318                     <div
class="col-sm-8">
319                         <div
class="input-group">
320                             <input type=
"text" class="form-control" id="db_server" name="db_server" placeholder="<?php echo htmlspecialchars($Translation['mysql server']); ?>" value="localhost">
321                             <span
class="input-group-btn">
322                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#db_server-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
323                             </span>
324                         </div>
325                         <span
class="help-block collapse" id="db_server-help"><?php echo $Translation['db_server help']; ?></span>
326                     </div>
327                 </div>
328
329                 <div
class="form-group">
330                     <label
for="db_name" class="control-label col-sm-4"><?php echo $Translation['mysql db']; ?></label>
331                     <div
class="col-sm-8">
332                         <div
class="input-group">
333                             <input type=
"text" class="form-control" id="db_name" name="db_name" placeholder="<?php echo htmlspecialchars($Translation['mysql db']); ?>">
334                             <span
class="input-group-btn">
335                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#db_name-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
336                             </span>
337                         </div>
338                         <span
class="help-block collapse" id="db_name-help"><?php echo $Translation['db_name help']; ?></span>
339                     </div>
340                 </div>
341
342                 <div
class="form-group">
343                     <label
for="db_username" class="control-label col-sm-4"><?php echo $Translation['mysql username']; ?></label>
344                     <div
class="col-sm-8">
345                         <div
class="input-group">
346                             <input type=
"text" class="form-control" id="db_username" name="db_username" placeholder="<?php echo htmlspecialchars($Translation['mysql username']); ?>">
347                             <span
class="input-group-btn">
348                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#db_username-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
349                             </span>
350                         </div>
351                         <span
class="help-block collapse" id="db_username-help"><?php echo $Translation['db_username help']; ?></span>
352                     </div>
353                 </div>
354
355                 <div
class="form-group">
356                     <label
for="db_password" class="control-label col-sm-4"><?php echo $Translation['mysql password']; ?></label>
357                     <div
class="col-sm-8">
358                         <div
class="input-group">
359                             <input type=
"password" class="form-control" id="db_password" name="db_password" placeholder="<?php echo htmlspecialchars($Translation['mysql password']); ?>">
360                             <span
class="input-group-btn">
361                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#db_password-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
362                             </span>
363                         </div>
364                         <span
class="help-block collapse" id="db_password-help"><?php echo $Translation['db_password help']; ?></span>
365                     </div>
366                 </div>
367
368                 <div id=
"db_test" class="alert" style="display: none;"></div>
369             </fieldset>
370
371             <fieldset
class="form-horizontal" id="inputs">
372                 <legend><?php echo $Translation[
'Admin Information']; ?></legend>
373
374                 <div
class="row form-group">
375                     <label
for="username" class="control-label col-sm-4"><?php echo $Translation['username']; ?></label>
376                     <div
class="col-sm-8">
377                         <div
class="input-group">
378                             <input type=
"text" required class="form-control" id="username" name="username" placeholder="<?php echo htmlspecialchars($Translation['username']); ?>">
379                             <span
class="input-group-btn">
380                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#username-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
381                             </span>
382                         </div>
383                         <span
class="help-block collapse" id="username-help"><?php echo $Translation['username help']; ?></span>
384                     </div>
385                 </div>
386
387                 <div
class="form-group">
388                     <label
for="email" class="control-label col-sm-4"><?php echo $Translation['email']; ?></label>
389                     <div
class="col-sm-8">
390                         <div
class="input-group">
391                             <input type=
"text" required class="form-control" id="email" name="email" placeholder="<?php echo htmlspecialchars($Translation['email']); ?>">
392                             <span
class="input-group-btn">
393                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#email-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
394                             </span>
395                         </div>
396                         <span
class="help-block collapse" id="email-help"><?php echo $Translation['email help']; ?></span>
397                     </div>
398                 </div>
399             </fieldset>
400
401             <div
class="row">
402                 <div
class="col-sm-6">
403                     <div
class="form-group">
404                         <label
for="password" class="control-label"><?php echo $Translation['password']; ?></label>
405                         <div
class="input-group">
406                             <input type=
"password" required class="form-control" id="password" name="password" placeholder="<?php echo htmlspecialchars($Translation['password']); ?>">
407                             <span
class="input-group-btn">
408                                 <button data-toggle=
"collapse" tabindex="-1" data-target="#password-help" class="btn btn-info" type="button"><i class="glyphicon glyphicon-info-sign"></i></button>
409                             </span>
410                         </div>
411                         <span
class="help-block collapse" id="password-help"><?php echo $Translation['password help']; ?></span>
412                     </div>
413                 </div>
414                 <div
class="col-sm-6">
415                     <div
class="form-group">
416                         <label
for="confirmPassword" class="control-label"><?php echo $Translation['confirm password']; ?></label>
417                         <input type=
"password" required class="form-control" id="confirmPassword" name="confirmPassword" placeholder="<?php echo htmlspecialchars($Translation['confirm password']); ?>">
418                     </div>
419                 </div>
420             </div>
421
422             <div
class="row">
423                 <div
class="col-sm-offset-3 col-sm-6">
424                     <button
class="btn btn-primary btn-lg btn-block" value="submit" id="submit" type="submit" name="submit"><?php echo $Translation['Submit']; ?></button>
425                 </div>
426             </div>
427         </form>
428
429     <?php }elseif($finish){ ?>
430
431         <?php
432             
// make sure this is an admin
433             
if(!$_SESSION['adminUsername']){
434                 ?>
435                 <div id=
"manual-redir" style="width: 400px; margin: 10px auto;">If not redirected automatically, <a href="index.php">click here</a>!</div>
436                 <script>
437                     window.location =
'index.php';
438                 </script>
439                 <?php
440                 exit;
441             }
442         ?>
443
444         <div
class="instructions">
445             <p style=
"background-color: white; padding: 20px; margin-bottom: 40px; border-radius: 4px;"><img src="logo.png"></p>
446             <div
class="panel panel-success">
447                 <div
class="panel-heading">
448                     <h3
class="panel-title"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['setup finished']; ?></h3>
449                 </div>
450                 <div
class="panel-content">
451                     <ul id=
"next-actions" class="nav nav-pills nav-stacked">
452                         <li
class="acive"><a href="index.php"><i class="glyphicon glyphicon-play"></i> <b><?php echo $Translation['setup next 1']; ?></b></a></li>
453                         <li><a href=
"admin/pageUploadCSV.php"><i class="glyphicon glyphicon-upload"></i> <?php echo $Translation['setup next 2']; ?></a></li>
454                         <li><a href=
"admin/pageHome.php"><i class="glyphicon glyphicon-cog"></i> <?php echo $Translation['setup next 3']; ?></a></li>
455                     </ul>
456                 </div>
457             </div>
458         </div>
459
460     <?php } ?>
461     </div></div>
462
463     <script>
464     <?php
if(!$form && !$finish){ ?>
465         $j(function() {
466             $(
'show-intro2').observe('click', function(){
467                 $(
'intro1').hide();
468                 $(
'intro2').appear({ duration: 2 });
469             });
470             $(
'show-login-form').observe('click', function(){
471                 
var a = window.location.href;
472                 window.location = a +
'?show-form=1';
473             });
474         });
475     <?php }elseif($form){ ?>
476         $j(function() {
477             
/* password strength feedback */
478             $(
'password').observe('keyup', function(){
479                 ps = passwordStrength($F(
'password'), $F('username'));
480
481                 
if(ps == 'strong'){
482                     $j(
'#password').parents('.form-group').removeClass('has-error has-warning').addClass('has-success');
483                     $(
'password').title = '<?php echo htmlspecialchars($Translation['Password strength: strong']); ?>';
484                 }
else if(ps == 'good'){
485                     $j(
'#password').parents('.form-group').removeClass('has-error has-success').addClass('has-warning');
486                     $(
'password').title = '<?php echo htmlspecialchars($Translation['Password strength: good']); ?>';
487                 }
else{
488                     $j(
'#password').parents('.form-group').removeClass('has-success has-warning').addClass('has-error');
489                     $(
'password').title = '<?php echo htmlspecialchars($Translation['Password strength: weak']); ?>';
490                 }
491             });
492
493             
/* inline feedback of confirm password */
494             $(
'confirmPassword').observe('keyup', function(){
495                 
if($F('confirmPassword') != $F('password') || !$F('confirmPassword').length){
496                     $j(
'#confirmPassword').parents('.form-group').removeClass('has-success').addClass('has-error');
497                 }
else{
498                     $j(
'#confirmPassword').parents('.form-group').removeClass('has-error').addClass('has-success');
499                 }
500             });
501
502             
/* inline feedback of email */
503             $(
'email').observe('change', function(){
504                 
if(validateEmail($F('email'))){
505                     $j(
'#email').parents('.form-group').removeClass('has-error').addClass('has-success');
506                 }
else{
507                     $j(
'#email').parents('.form-group').removeClass('has-success').addClass('has-error');
508                 }
509             });
510
511             $(
'login-form').appear({ duration: 2 });
512             setTimeout(
"$('db_name').focus();", 2006);
513
514             $(
'db_name').observe('change', function(){ db_test(); });
515             $(
'db_password').observe('change', function(){ db_test(); });
516             $(
'db_server').observe('change', function(){ db_test(); });
517             $(
'db_username').observe('change', function(){ db_test(); });
518         });
519
520         
/* validate data before submitting */
521         function jsValidateSetup(){
522             
var p1 = $F('password');
523             
var p2 = $F('confirmPassword');
524             
var user = $F('username');
525             
var email = $F('email');
526
527             
/* passwords not matching? */
528             
if(p1 != p2){
529                 modal_window({ message:
'<div class="alert alert-danger"><?php echo addslashes($Translation['password no match']); ?></div>', title: "<?php echo addslashes($Translation['error:']); ?>", close: function(){ jQuery('#confirmPassword').focus(); } });
530                 
return false;
531             }
532
533             
/* user exists? */
534             
if($('usernameNotAvailable').visible()){
535                 modal_window({ message:
'<div class="alert alert-danger"><?php echo addslashes($Translation['username invalid']); ?></div>', title: "<?php echo addslashes($Translation['error:']); ?>", close: function(){ jQuery('#username').focus(); } });
536                 
return false;
537             }
538
539             
return true;
540         }
541
542         
/* test db info */
543         
var db_test_in_progress = false;
544         function db_test(){
545             
if(db_test_in_progress) return;
546
547             
if($F('db_name').length && $F('db_username').length && $F('db_server').length && $$('#db_password:focus') == ''){
548                 setTimeout(function(){
549                     
if(db_test_in_progress) return;
550
551                     
new Ajax.Request(
552                         
'<?php echo basename(__FILE__); ?>', {
553                             method:
'post',
554                             parameters: {
555                                 db_name: $F(
'db_name'),
556                                 db_server: $F(
'db_server'),
557                                 db_password: $F(
'db_password'),
558                                 db_username: $F(
'db_username'),
559                                 test:
1
560                             },
561                             onCreate: function() {
562                                 db_test_in_progress =
true;
563                             },
564                             onSuccess: function(resp) {
565                                 
if(resp.responseText == 'SUCCESS!'){
566                                     $(
'db_test').removeClassName('alert-danger').addClassName('alert-success').update('<?php echo addslashes($Translation['Database info is correct']); ?>').appear();
567                                 }
else if(resp.responseText.match(/^ERROR!/)){
568                                     $(
'db_test').removeClassName('alert-success').addClassName('alert-danger').update('<?php echo addslashes($Translation['Database connection error']); ?>').show();
569                                     Effect.Shake(
'db_test');
570                                 }
571                             },
572                             onComplete: function() {
573                                 db_test_in_progress =
false;
574                             }
575                         }
576                     );
577                 },
1000);
578             }
579         }
580     <?php } ?>
581     </script>
582
583     <style>
584         legend{ font-weight: bold; }
585         #usernameAvailable,#usernameNotAvailable{ cursor: pointer; }
586
587         .instructions{
588             padding: 30px;
589             margin: 40px auto;
590             border: solid 1px silver;
591             border-radius: 4px;
592         }
593         .instructions img{ display: block; margin: auto; }
594         .instructions .buttons{
595             display: block;
596             height: 1px;
597             margin: 30px auto;
598         }
599         ul#next-actions li { font-size:
1.3em; }
600         ul#next-actions { padding: 2em; }
601     </style>
602
603 <?php include_once(
"$curr_dir/footer.php"); ?>


Gõ tìm kiếm nhanh...